package com.files;

import com.files.chain.FileChain;
import com.files.service.impl.DiskFileServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

@SpringBootApplication
@EnableAspectJAutoProxy
public class FilesApplication {


    @Autowired
    DiskFileServiceImpl diskFileService;

    public static void main(String[] args) {
        SpringApplication.run(FilesApplication.class);
    }

    @Bean
    CommandLineRunner init() {
        return (args) -> {
            registerFileListener();
        };
    }

    void registerFileListener(){
        FileChain.RegisterListensers(diskFileService);
    }

}
